package 题目集.二分;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//https://www.acwing.com/problem/content/1462/
public class ch06_我在哪 {
    static String str;
    static int n;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sc.nextLine();
        str = sc.nextLine();
        System.out.println(find());
    }

    public static int find() {
        int l = 1, r = n;
        while (l <= r) {
            int m = l + r >> 1;
            if (check(m)) {
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        if (r >= 1&&check(r)) {
            return r;
        }
        return l;
    }


    public static boolean check(int k) {
        int end=n-k;
        Set<String> set=new HashSet<>();
        for (int i = 0; i <= end; i++) {
            String cur = str.substring(i, i + k);
            if (set.contains(cur)){
                return false;
            }
            set.add(cur);
        }
        return true;
    }
}
